<?php

namespace Trawind\Extension\Traits;

use Trawind\Extension\Models\Deploy\Language;

trait HasLanguage
{

    /*
     * 统一输出，transformer层加入：
         public function includeLanguages($model)
        {
            $data = [];
            if (!is_null($languages = $model->languages)) {
                foreach ($languages as $language) {
                    $data[$language['field']][$language['language']] = $language['content'];
                }
            }
    
            return $this->primitive($data);
        }
     * */
    public function languages()
    {
        return $this->morphMany(Language::class, 'business');
    }
    
}